package com.java.singletonpattern;

/**
 * @author luzhikun
 * @date 2020/12/9-21:43
 * 懒汉式
 */
public class LazySingleton {
    public static void main(String[] args) {
        LazySing lazySing = LazySing.getInstance();
        LazySing lazySing1 = LazySing.getInstance();
        System.out.println(lazySing1);
        System.out.println(lazySing);

    }
}

class LazySing {
    private LazySing() {

    }

    private static LazySing lazySing = null;

    public static LazySing getInstance() {
        if (lazySing == null) {
            lazySing = new LazySing();
        }
        return lazySing;
    }

}
